/*
 * Author Anju
 */
package com.sdi.columbus;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

public class GpsFetchData {
	
    public String Login(String accountID, String Username,String Password) throws ClientProtocolException, IOException, JSONException
    
    {
    	
    	String result="";
    	
    	// Add your data
    	
    	JSONObject user =  new JSONObject();
    	user.put("userID", Username);
    	user.put("password", Password);
    	user.put("accountID", accountID);
    	
    	// Create a new HttpClient and Post Header
    	
    	HttpClient client = new DefaultHttpClient();
    	URI website;
		try {
			website = new URI("http://deepam.cloudapp.net/ColumbusRESTService/ColumbusREST.svc/json/Login");
			HttpPost request = new HttpPost();
	    	request.setEntity(new StringEntity(user.toString()));
	    	request.addHeader("content-type", "application/json");      
	    	request.setURI(website);
	    	
	    	// Execute HTTP Post Request
	    	HttpResponse response = client.execute(request);
	    	HttpEntity entity = response.getEntity();
			result = EntityUtils.toString(entity);
	    	

	    	System.out.println("Hai From gpsfetchdata"+response);
	    	System.out.println("Response in readable form"+result);
		} catch (URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
		return result; 	
    	
    	
    }    
}